#include "gsmeg.h"

void print_gsmeg(z_gsmeg_t *gsmeg_msg){
    Z_LOG_NOTICE("gsmeg head:gems_magic_num[%u] gems_logid[%u] size[%u] flag[%u] cmd[%X] param[%d] logid[%u] seq[%u] attach[%U] checksum[%s] reserved[%u]",gsmeg_msg->magic_num_,gsmeg_msg->log_id_,gsmeg_msg->size_,gsmeg_msg->flag_,gsmeg_msg->cmd_,gsmeg_msg->param_,gsmeg_msg->logid_,gsmeg_msg->seq_,gsmeg_msg->attach_,gsmeg_msg->checksum_,gsmeg_msg->reserved_);    
    z_buffer_t bf = {
          .used_ = gsmeg_msg->size_ - sizeof(z_gsmeg_t),
          .size_ = gsmeg_msg->size_ - sizeof(z_gsmeg_t),
          .ptr_  = (char*)(gsmeg_msg+1),
    };
    if(0 < bf.used_){ 
        Z_LOG_NOTICE("gsmeg body:[%b]",(&bf));  
    }
}


static int is_in_cmd_blacklist(z_hash_t * blacklist, long long cmd){
    if(NULL==zH_llfind(blacklist,cmd)){
        Z_LOG_DEBUG("cmd[%X] is not find! ",cmd); 
        return FALSE;
    }else{  
        return TRUE;
    }
}

void print_gsmeg_blacklist(z_hash_t * blacklist, z_gsmeg_t *gsmeg_msg){
    if(gsmeg_msg){
        if(FALSE == is_in_cmd_blacklist(blacklist, gsmeg_msg->cmd_)){
            print_gsmeg(gsmeg_msg);
        }else{  
            Z_LOG_NOTICE("cmd[%X] not print cos in print blacklist",gsmeg_msg->cmd_);
        }    
    }else{    
        Z_LOG_ERROR("gsmeg_msg is NULL!!!");
    }
}


